/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2014 All Rights Reserved.
 */
package com.h2o3.sample.handler;

import org.springframework.beans.factory.annotation.Autowired;

import com.h2o3.carmack.message.Message;
import com.h2o3.carmack.message.annotation.Handler;
import com.h2o3.carmack.message.annotation.HandlerMapping;
import com.h2o3.carmack.session.Session;
import com.h2o3.sample.service.ChatService;

/**
 * @author chensheng
 * @version $Id: MessageHandler.java, v 0.1 1/22/14 6:39 PM chensheng Exp $
 */
@Handler
public class MessageHandler {
    @Autowired
    private ChatService chatService;

    @HandlerMapping("message")
    public void handle(Session session, Message message) {
        String content = message.getBody(String.class);

        chatService.sendMessage(session, content);
    }

    public ChatService getChatService() {
        return chatService;
    }

    public void setChatService(ChatService chatService) {
        this.chatService = chatService;
    }
}
